// http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript

function rdmStr1(len) {
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for (var i = 0; i < len; i++)
        text += possible.charAt(Math.floor(Math.random() * possible.length));
    return text;
}

function rdmStr2(len) {
    return Math.random().toString(36).substring(len);
}

var len = 5;
console.log(rdmStr1(len));
console.log(rdmStr2(len));